﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

public partial class JobSearchResult : System.Web.UI.Page
{
    string industryset = "", skillset = "", fun = "", minexp = "", maxexp = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["mode"] != null && Request.QueryString["industryset"] != null)
            {
                if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "ByIndustry")
                {
                    industryset = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["industryset"]));
                    FillGrdByIndustry(industryset, Navigation.First);
                }
            }
            if (Request.QueryString["mode"] != null && Request.QueryString["skillset"] != null)
            {
                if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "BySkills")
                {
                    skillset = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["skillset"]));
                    FillGrdBySkills(skillset, Navigation.First);
                }
            }

            if (Request.QueryString["mode"] != null && Request.QueryString["minexp"] != null && Request.QueryString["functionalarea"] != null)
            {
                if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "ByExperience")
                {
                    minexp = "0";
                    fun = "0";
                    if (Request.QueryString["minexp"] != null)
                        minexp = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["minexp"]));
                    if (Request.QueryString["functionalarea"] != null)
                        fun = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["functionalarea"]));
                    FillgrdByExperience(minexp, fun, Navigation.First);
                }
            }
            if (Request.QueryString["mode"] != null)
            {
                if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "Advanced")
                {
                    string sk = "", ind = "", fun = "0", minexp = "0", maxexp = "0", jobl = "0";
                    if (Request.QueryString["skillset"] != null)
                        sk = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["skillset"]));
                    if (Request.QueryString["industryset"] != null)
                        ind = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["industryset"]));
                    if (Request.QueryString["functionalarea"] != null)
                        fun = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["functionalarea"]));
                    if (Request.QueryString["minexperience"] != null)
                        minexp = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["minexperience"]));
                    if (Request.QueryString["maxexperience"] != null)
                        maxexp = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["maxexperience"]));
                    if (Request.QueryString["joblocation"] != null)
                        jobl = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["joblocation"]));
                    FillgrdByAdvance(sk, ind, minexp, maxexp, fun, jobl, Navigation.First);
                }
            }
        }
    }

    protected void FillgrdByAdvance(string sk, string ind, string minexp, string maxexp, string fun, string jobl, Navigation navigation)
    {
        try
        {
            clsSearchJob objclsSearchJob = new clsSearchJob();
            List<clsSearchResult> objclsSearchResultList = new List<clsSearchResult>();
            clsSearchResult objclsSearchResult = new clsSearchResult();
            objclsSearchResultList = objclsSearchJob.GetJobAdvanceSearch(sk, ind, Convert.ToInt32(minexp), Convert.ToInt32(maxexp), Convert.ToInt32(fun), Convert.ToInt32(jobl));
            if (objclsSearchResultList != null)
            {
                if (objclsSearchResultList.Count > 0)
                {
                    rptrSearchByIndustry.DataSource = objclsSearchResultList;
                    rptrSearchByIndustry.DataBind();
                    PagedDataSource objPds = new PagedDataSource();
                    objPds.DataSource = objclsSearchResultList;
                    objPds.AllowPaging = true;
                    objPds.PageSize = int.Parse(ddlPageSize.SelectedValue);
                    switch (navigation)
                    {
                        case Navigation.Next:       //Increment NowViewing by 1
                            NowViewing++;
                            break;
                        case Navigation.Previous:   //Decrement NowViewing by 1
                            NowViewing--;
                            break;
                        case Navigation.Last:       //Make NowViewing to last page for PagedDataSource
                            NowViewing = objPds.PageCount - 1;
                            break;
                        case Navigation.Pager:      //Change NowViewing based on pager size and page count
                            if (int.Parse(ddlPageSize.SelectedValue) >= objPds.PageCount)
                                NowViewing = objPds.PageCount - 1;
                            break;
                        case Navigation.Sorting:
                            break;
                        default:                    //Default NowViewing set to 0
                            NowViewing = 0;
                            break;
                    }

                    objPds.CurrentPageIndex = NowViewing;
                    lblCurrentPage.Text = "Now viewing : " + (NowViewing + 1).ToString() + " of " + objPds.PageCount.ToString();
                    // Disable Prev, Next, First, Last buttons if necessary
                    lbtnPrev.Enabled = !objPds.IsFirstPage;
                    lbtnNext.Enabled = !objPds.IsLastPage;
                    lbtnFirst.Enabled = !objPds.IsFirstPage;
                    lbtnLast.Enabled = !objPds.IsLastPage;
                    dvNoRecords.Visible = false;
                }
                else
                {
                    rptrSearchByIndustry.DataSource = null;
                    rptrSearchByIndustry.DataBind();
                    dvNoRecords.Visible = true;
                }
            }

        }
        catch (Exception)
        {
            throw;
        }
    }

    protected void FillgrdByExperience(string minexp, string maxexp, Navigation navigation)
    {
        try
        {
            clsSearchJob objclsSearchJob = new clsSearchJob();
            List<clsSearchResult> objclsSearchResultList = new List<clsSearchResult>();
            clsSearchResult objclsSearchResult = new clsSearchResult();
            objclsSearchResultList = objclsSearchJob.GetJobByExperience(Convert.ToInt32(minexp), Convert.ToInt32(maxexp));
            if (objclsSearchResultList != null)
            {
                if (objclsSearchResultList.Count > 0)
                {
                    rptrSearchByIndustry.DataSource = objclsSearchResultList;
                    rptrSearchByIndustry.DataBind();
                    PagedDataSource objPds = new PagedDataSource();
                    objPds.DataSource = objclsSearchResultList;
                    objPds.AllowPaging = true;
                    objPds.PageSize = int.Parse(ddlPageSize.SelectedValue);
                    switch (navigation)
                    {
                        case Navigation.Next:       //Increment NowViewing by 1
                            NowViewing++;
                            break;
                        case Navigation.Previous:   //Decrement NowViewing by 1
                            NowViewing--;
                            break;
                        case Navigation.Last:       //Make NowViewing to last page for PagedDataSource
                            NowViewing = objPds.PageCount - 1;
                            break;
                        case Navigation.Pager:      //Change NowViewing based on pager size and page count
                            if (int.Parse(ddlPageSize.SelectedValue) >= objPds.PageCount)
                                NowViewing = objPds.PageCount - 1;
                            break;
                        case Navigation.Sorting:
                            break;
                        default:                    //Default NowViewing set to 0
                            NowViewing = 0;
                            break;
                    }

                    objPds.CurrentPageIndex = NowViewing;
                    lblCurrentPage.Text = "Now viewing : " + (NowViewing + 1).ToString() + " of " + objPds.PageCount.ToString();
                    // Disable Prev, Next, First, Last buttons if necessary
                    lbtnPrev.Enabled = !objPds.IsFirstPage;
                    lbtnNext.Enabled = !objPds.IsLastPage;
                    lbtnFirst.Enabled = !objPds.IsFirstPage;
                    lbtnLast.Enabled = !objPds.IsLastPage;
                    dvNoRecords.Visible = false;
                }
                else
                {
                    rptrSearchByIndustry.DataSource = null;
                    rptrSearchByIndustry.DataBind();
                    dvNoRecords.Visible = true;
                }
            }

        }
        catch (Exception)
        {
            throw;
        }
    }

    protected void FillGrdByIndustry(string industries, Navigation navigation)
    {
        try
        {
            string[] IndustrySet = industries.Trim().ToLower().Split(',');
            clsSearchJob objclsSearchJob = new clsSearchJob();
            List<clsSearchResult> objclsSearchResultList = new List<clsSearchResult>();
            clsSearchResult objclsSearchResult = new clsSearchResult();
            objclsSearchResultList = objclsSearchJob.GetJobByIndustry(IndustrySet);
            if (objclsSearchResultList != null)
            {
                if (objclsSearchResultList.Count > 0)
                {
                    rptrSearchByIndustry.DataSource = objclsSearchResultList;
                    rptrSearchByIndustry.DataBind();
                    PagedDataSource objPds = new PagedDataSource();
                    objPds.DataSource = objclsSearchResultList;
                    objPds.AllowPaging = true;
                    objPds.PageSize = int.Parse(ddlPageSize.SelectedValue);
                    switch (navigation)
                    {
                        case Navigation.Next:       //Increment NowViewing by 1
                            NowViewing++;
                            break;
                        case Navigation.Previous:   //Decrement NowViewing by 1
                            NowViewing--;
                            break;
                        case Navigation.Last:       //Make NowViewing to last page for PagedDataSource
                            NowViewing = objPds.PageCount - 1;
                            break;
                        case Navigation.Pager:      //Change NowViewing based on pager size and page count
                            if (int.Parse(ddlPageSize.SelectedValue) >= objPds.PageCount)
                                NowViewing = objPds.PageCount - 1;
                            break;
                        case Navigation.Sorting:
                            break;
                        default:                    //Default NowViewing set to 0
                            NowViewing = 0;
                            break;
                    }

                    objPds.CurrentPageIndex = NowViewing;
                    lblCurrentPage.Text = "Now viewing : " + (NowViewing + 1).ToString() + " of " + objPds.PageCount.ToString();
                    // Disable Prev, Next, First, Last buttons if necessary
                    lbtnPrev.Enabled = !objPds.IsFirstPage;
                    lbtnNext.Enabled = !objPds.IsLastPage;
                    lbtnFirst.Enabled = !objPds.IsFirstPage;
                    lbtnLast.Enabled = !objPds.IsLastPage;
                    dvNoRecords.Visible = false;
                }
                else
                {
                    rptrSearchByIndustry.DataSource = null;
                    rptrSearchByIndustry.DataBind();
                    dvNoRecords.Visible = true;
                }
            }
        }
        catch (Exception)
        {
            throw;
        }
    }

    protected void FillGrdBySkills(string skills, Navigation navigation)
    {
        try
        {
            string[] SkillSet = skills.Trim().ToLower().Split(',');
            clsSearchJob objclsSearchJob = new clsSearchJob();
            List<clsSearchResult> objclsSearchResultList = new List<clsSearchResult>();
            clsSearchResult objclsSearchResult = new clsSearchResult();
            objclsSearchResultList = objclsSearchJob.GetJobBySkills(SkillSet);
            if (objclsSearchResultList != null)
            {
                if (objclsSearchResultList.Count > 0)
                {
                    rptrSearchByIndustry.DataSource = objclsSearchResultList;
                    rptrSearchByIndustry.DataBind();
                    PagedDataSource objPds = new PagedDataSource();
                    objPds.DataSource = objclsSearchResultList;
                    objPds.AllowPaging = true;
                    objPds.PageSize = int.Parse(ddlPageSize.SelectedValue);
                    switch (navigation)
                    {
                        case Navigation.Next:       //Increment NowViewing by 1
                            NowViewing++;
                            break;
                        case Navigation.Previous:   //Decrement NowViewing by 1
                            NowViewing--;
                            break;
                        case Navigation.Last:       //Make NowViewing to last page for PagedDataSource
                            NowViewing = objPds.PageCount - 1;
                            break;
                        case Navigation.Pager:      //Change NowViewing based on pager size and page count
                            if (int.Parse(ddlPageSize.SelectedValue) >= objPds.PageCount)
                                NowViewing = objPds.PageCount - 1;
                            break;
                        case Navigation.Sorting:
                            break;
                        default:                    //Default NowViewing set to 0
                            NowViewing = 0;
                            break;
                    }

                    objPds.CurrentPageIndex = NowViewing;
                    lblCurrentPage.Text = "Now viewing : " + (NowViewing + 1).ToString() + " of " + objPds.PageCount.ToString();
                    // Disable Prev, Next, First, Last buttons if necessary
                    lbtnPrev.Enabled = !objPds.IsFirstPage;
                    lbtnNext.Enabled = !objPds.IsLastPage;
                    lbtnFirst.Enabled = !objPds.IsFirstPage;
                    lbtnLast.Enabled = !objPds.IsLastPage;
                    dvNoRecords.Visible = false;
                }
                else
                {
                    rptrSearchByIndustry.DataSource = null;
                    rptrSearchByIndustry.DataBind();
                    dvNoRecords.Visible = true;
                }
            }
        }
        catch (Exception ex)
        {
            throw;
        }
    }

    protected void rptrSearchByIndustry_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        try
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var lblJobLocation = (Label)e.Item.FindControl("lblJobLocation");
                var lblJobpostedOn = (Label)e.Item.FindControl("lblJobpostedOn");
                if (lblJobpostedOn.Text != "")
                {
                    DateTime jbp = Convert.ToDateTime(lblJobpostedOn.Text);
                    lblJobpostedOn.Text = jbp.ToString("dd-MMM-yyyy");
                }
                if (lblJobLocation.Text != "")
                {
                    int cc = Convert.ToInt32(lblJobLocation.Text);
                    clsCity objclsCity = new clsCity();
                    IN_TB_CITY objIN_TB_CITY = new IN_TB_CITY();
                    objIN_TB_CITY = objclsCity.GetCityById(cc);
                    if (objIN_TB_CITY != null)
                        lblJobLocation.Text = Convert.ToString(objIN_TB_CITY.CITY);
                }

                HiddenField hfJobPostId = (HiddenField)e.Item.FindControl("hfJobPostId");
                LinkButton lnkApplyNow = (LinkButton)e.Item.FindControl("lnkApplyNow");
                Label lblAlreadyApplied = (Label)e.Item.FindControl("lblAlreadyApplied");
                //clsJobsAppliedDAL objclsJobsAppliedDAL = new clsJobsAppliedDAL();
                if (Session["UserId"] != null && hfJobPostId.Value != "")
                {
                    clsJobsAppliedDAL objclsJobsAppliedDAL = new clsJobsAppliedDAL();
                    bool Result = objclsJobsAppliedDAL.IsJobApplied(Convert.ToInt32(Session["UserId"]), Convert.ToInt32(hfJobPostId.Value));
                    if (Result == true)
                    {
                        lblAlreadyApplied.Visible = true;
                        lnkApplyNow.Text = "Check Status";
                    }
                    else
                    {
                        lblAlreadyApplied.Visible = false;
                        lnkApplyNow.Text = "Apply";
                    }
                }

            }
        }
        catch (Exception)
        {
            throw;
        }
    }

    public int NowViewing
    {
        get
        {
            object obj = ViewState["_NowViewing"];
            if (obj == null)
                return 0;
            else
                return (int)obj;
        }
        set
        {
            this.ViewState["_NowViewing"] = value;
        }
    }

    protected override void OnInitComplete(EventArgs e)
    {
        base.OnInitComplete(e);
        ddlPageSize.SelectedIndexChanged += new EventHandler(ddlPageSize_SelectedIndexChanged);
    }

    void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (Request.QueryString["mode"] != null && Request.QueryString["industryset"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "ByIndustry")
            {
                industryset = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"]));
                FillGrdByIndustry(industryset, Navigation.Pager);
            }
        }
        if (Request.QueryString["mode"] != null && Request.QueryString["skillset"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "BySkills")
            {
                industryset = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["skillset"]));
                FillGrdBySkills(industryset, Navigation.Pager);
            }
        }
        if (Request.QueryString["mode"] != null && Request.QueryString["minexp"] != null && Request.QueryString["functionalarea"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "ByExperience")
            {
                minexp = "0";
                fun = "0";
                if (Request.QueryString["minexp"] != null)
                    minexp = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["minexp"]));
                if (Request.QueryString["functionalarea"] != null)
                    fun = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["functionalarea"]));
                FillgrdByExperience(minexp, maxexp, Navigation.Pager);
            }
        }
        if (Request.QueryString["mode"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "Advanced")
            {
                string sk = "", ind = "", fun = "0", minexp = "0", maxexp = "0", jobl = "0";
                if (Request.QueryString["skillset"] != null)
                    sk = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["skillset"]));
                if (Request.QueryString["industryset"] != null)
                    ind = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["industryset"]));
                if (Request.QueryString["functionalarea"] != null)
                    fun = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["functionalarea"]));
                if (Request.QueryString["minexperience"] != null)
                    minexp = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["minexperience"]));
                if (Request.QueryString["maxexperience"] != null)
                    maxexp = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["maxexperience"]));
                if (Request.QueryString["joblocation"] != null)
                    jobl = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["joblocation"]));
                FillgrdByAdvance(sk, ind, minexp, maxexp, fun, jobl, Navigation.Pager);
            }
        }
    }

    protected void lbtnPrev_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["mode"] != null && Request.QueryString["industryset"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "ByIndustry")
            {
                industryset = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"]));
                FillGrdByIndustry(industryset, Navigation.Previous);
            }
        }
        if (Request.QueryString["mode"] != null && Request.QueryString["skillset"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "BySkills")
            {
                industryset = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["skillset"]));
                FillGrdBySkills(industryset, Navigation.Previous);
            }
        }
        if (Request.QueryString["mode"] != null && Request.QueryString["minexp"] != null && Request.QueryString["functionalarea"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "ByExperience")
            {
                minexp = "0";
                fun = "0";
                if (Request.QueryString["minexp"] != null)
                    minexp = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["minexp"]));
                if (Request.QueryString["functionalarea"] != null)
                    fun = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["functionalarea"]));
                FillgrdByExperience(minexp, maxexp, Navigation.Previous);
            }
        }
        if (Request.QueryString["mode"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "Advanced")
            {
                string sk = "", ind = "", fun = "0", minexp = "0", maxexp = "0", jobl = "0";
                if (Request.QueryString["skillset"] != null)
                    sk = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["skillset"]));
                if (Request.QueryString["industryset"] != null)
                    ind = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["industryset"]));
                if (Request.QueryString["functionalarea"] != null)
                    fun = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["functionalarea"]));
                if (Request.QueryString["minexperience"] != null)
                    minexp = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["minexperience"]));
                if (Request.QueryString["maxexperience"] != null)
                    maxexp = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["maxexperience"]));
                if (Request.QueryString["joblocation"] != null)
                    jobl = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["joblocation"]));
                FillgrdByAdvance(sk, ind, minexp, maxexp, fun, jobl, Navigation.Previous);
            }
        }
    }
    protected void lbtnNext_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["mode"] != null && Request.QueryString["industryset"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "ByIndustry")
            {
                industryset = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["industryset"]));
                FillGrdByIndustry(industryset, Navigation.Next);
            }
        }
        if (Request.QueryString["mode"] != null && Request.QueryString["skillset"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "BySkills")
            {
                industryset = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["skillset"]));
                FillGrdBySkills(industryset, Navigation.Next);
            }
        }
        if (Request.QueryString["mode"] != null && Request.QueryString["minexp"] != null && Request.QueryString["functionalarea"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "ByExperience")
            {
                minexp = "0";
                fun = "0";
                if (Request.QueryString["minexp"] != null)
                    minexp = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["minexp"]));
                if (Request.QueryString["functionalarea"] != null)
                    fun = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["functionalarea"]));
                FillgrdByExperience(minexp, maxexp, Navigation.Next);
            }
        }
        if (Request.QueryString["mode"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "Advanced")
            {
                string sk = "", ind = "", fun = "0", minexp = "0", maxexp = "0", jobl = "0";
                if (Request.QueryString["skillset"] != null)
                    sk = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["skillset"]));
                if (Request.QueryString["industryset"] != null)
                    ind = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["industryset"]));
                if (Request.QueryString["functionalarea"] != null)
                    fun = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["functionalarea"]));
                if (Request.QueryString["minexperience"] != null)
                    minexp = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["minexperience"]));
                if (Request.QueryString["maxexperience"] != null)
                    maxexp = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["maxexperience"]));
                if (Request.QueryString["joblocation"] != null)
                    jobl = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["joblocation"]));
                FillgrdByAdvance(sk, ind, minexp, maxexp, fun, jobl, Navigation.Next);
            }
        }
    }
    protected void lbtnFirst_Click(object sender, EventArgs e)
    {
        if (Request.QueryString["mode"] != null && Request.QueryString["industryset"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "ByIndustry")
            {
                industryset = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"]));
                FillGrdByIndustry(industryset, Navigation.First);
            }
        }
        if (Request.QueryString["mode"] != null && Request.QueryString["skillset"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "BySkills")
            {
                industryset = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["skillset"]));
                FillGrdBySkills(industryset, Navigation.First);
            }
        }
        if (Request.QueryString["mode"] != null && Request.QueryString["minexp"] != null && Request.QueryString["functionalarea"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "ByExperience")
            {
                minexp = "0";
                fun = "0";
                if (Request.QueryString["minexp"] != null)
                    minexp = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["minexp"]));
                if (Request.QueryString["functionalarea"] != null)
                    fun = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["functionalarea"]));
                FillgrdByExperience(minexp, maxexp, Navigation.First);
            }
        }
        if (Request.QueryString["mode"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "Advanced")
            {
                string sk = "", ind = "", fun = "0", minexp = "0", maxexp = "0", jobl = "0";
                if (Request.QueryString["skillset"] != null)
                    sk = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["skillset"]));
                if (Request.QueryString["industryset"] != null)
                    ind = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["industryset"]));
                if (Request.QueryString["functionalarea"] != null)
                    fun = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["functionalarea"]));
                if (Request.QueryString["minexperience"] != null)
                    minexp = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["minexperience"]));
                if (Request.QueryString["maxexperience"] != null)
                    maxexp = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["maxexperience"]));
                if (Request.QueryString["joblocation"] != null)
                    jobl = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["joblocation"]));
                FillgrdByAdvance(sk, ind, minexp, maxexp, fun, jobl, Navigation.First);
            }
        }
    }
    protected void lbtnLast_Click(object sender, ImageClickEventArgs e)
    {
        if (Request.QueryString["mode"] != null && Request.QueryString["industryset"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "ByIndustry")
            {
                industryset = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["industryset"]));
                FillGrdByIndustry(industryset, Navigation.Last);
            }
        }
        if (Request.QueryString["mode"] != null && Request.QueryString["skillset"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "BySkills")
            {
                industryset = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["skillset"]));
                FillGrdBySkills(industryset, Navigation.Last);
            }
        }
        if (Request.QueryString["mode"] != null && Request.QueryString["minexp"] != null && Request.QueryString["functionalarea"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "ByExperience")
            {
                minexp = "0";
                fun = "0";
                if (Request.QueryString["minexp"] != null)
                    minexp = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["minexp"]));
                if (Request.QueryString["functionalarea"] != null)
                    fun = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["functionalarea"]));
                FillgrdByExperience(minexp, maxexp, Navigation.Last);
            }
        }
        if (Request.QueryString["mode"] != null)
        {
            if (clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["mode"])) == "Advanced")
            {
                string sk = "", ind = "", fun = "0", minexp = "0", maxexp = "0", jobl = "0";
                if (Request.QueryString["skillset"] != null)
                    sk = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["skillset"]));
                if (Request.QueryString["industryset"] != null)
                    ind = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["industryset"]));
                if (Request.QueryString["functionalarea"] != null)
                    fun = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["functionalarea"]));
                if (Request.QueryString["minexperience"] != null)
                    minexp = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["minexperience"]));
                if (Request.QueryString["maxexperience"] != null)
                    maxexp = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["maxexperience"]));
                if (Request.QueryString["joblocation"] != null)
                    jobl = clsEncryptionDecryption.DecryptQueryString(Convert.ToString(Request.QueryString["joblocation"]));
                FillgrdByAdvance(sk, ind, minexp, maxexp, fun, jobl, Navigation.Last);
            }
        }
    }

    protected void rptrSearchByIndustry_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "ApplyJob")
        {
            if (Session["UserId"] != null)
            {
                int JobPostId = Convert.ToInt32(e.CommandArgument.ToString());
                if (JobPostId != 0)
                {
                    LinkButton objLinkbutton = (LinkButton)e.CommandSource;
                    HiddenField hfJobPostId = (HiddenField)e.Item.FindControl("hfJobPostId");
                    if (hfJobPostId.Value != "")
                    {
                        int Job_PostId = Convert.ToInt32(hfJobPostId.Value.ToString());
                        clsSearchJob objclsSearchJob = new clsSearchJob();
                        clsSearchResult objclsSearchResult = objclsSearchJob.GetJobByJobPostId(Job_PostId);
                        string postid = Convert.ToString(Job_PostId);
                        postid = clsEncryptionDecryption.EncryptQueryString(postid);
                        string companyname = Convert.ToString(objclsSearchResult.COMPANY_NAME);
                        companyname = clsEncryptionDecryption.EncryptQueryString(companyname);
                        string companydetails = Convert.ToString(objclsSearchResult.COMPANY_DESCRIPTION);
                        companydetails = clsEncryptionDecryption.EncryptQueryString(companydetails);
                        string jobtitle = Convert.ToString(objclsSearchResult.JOB_TITLE);
                        jobtitle = clsEncryptionDecryption.EncryptQueryString(jobtitle);
                        string jobdesc = Convert.ToString(objclsSearchResult.JOB_DESCRIPTION);
                        jobdesc = clsEncryptionDecryption.EncryptQueryString(jobdesc);
                        string skillsreq = Convert.ToString(objclsSearchResult.SKILLS_REQUIRED);
                        skillsreq = clsEncryptionDecryption.EncryptQueryString(skillsreq);
                        string joblocid = Convert.ToString(objclsSearchResult.JOB_LOCATION);
                        joblocid = clsEncryptionDecryption.EncryptQueryString(joblocid);
                        string expreq = Convert.ToString(objclsSearchResult.EXPERIENCE_REQUIRED);
                        expreq = clsEncryptionDecryption.EncryptQueryString(expreq);
                        string qualificationreq = Convert.ToString(objclsSearchResult.QUALIFICATION_REQUIRED);
                        qualificationreq = clsEncryptionDecryption.EncryptQueryString(qualificationreq);
                        string salaryoffered = Convert.ToString(objclsSearchResult.SALARY_OFFERED);
                        salaryoffered = clsEncryptionDecryption.EncryptQueryString(salaryoffered);
                        string functionalareaid = Convert.ToString(objclsSearchResult.FUNCTIONAL_AREA);
                        functionalareaid = clsEncryptionDecryption.EncryptQueryString(functionalareaid);
                        string jobpostedon = Convert.ToString(objclsSearchResult.JOB_POSTED_ON);
                        jobpostedon = clsEncryptionDecryption.EncryptQueryString(jobpostedon);

                        if (Request.QueryString["roleid"] != null)
                            Response.Redirect("Job_Details.aspx?roleid=" + Request.QueryString["roleid"].ToString() + "&postid=" + postid + "&companyname=" + companyname + "&companydetails=" + companydetails + "&jobtitle=" + jobtitle + "&jobdesc=" + jobdesc + "&skillsreq=" + skillsreq + "&joblocid=" + joblocid + "&expreq=" + expreq + "&qualificationreq=" + qualificationreq + "&salaryoffered=" + salaryoffered + "&functionalareaid=" + functionalareaid + "&jobpostedon=" + jobpostedon);
                        else
                        {
                            Response.Redirect("JobSeekerLogin.aspx");
                        }

                    }
                }
                else
                {
                    Response.Redirect("JobSeekerLogin.aspx");
                }
            }
            else
            {
                Response.Redirect("JobSeekerLogin.aspx");
            }
        }

    }

}
